package com.xuecheng.content.controller;

import com.xuecheng.api.content.CourseTeacherApi;
import com.xuecheng.api.content.model.dto.CourseTeacherDTO;
import com.xuecheng.api.content.model.vo.CourseTeacherVO;
import com.xuecheng.common.util.SecurityUtil;
import com.xuecheng.content.convert.CourseTeacherConvert;
import com.xuecheng.content.service.CourseTeacherService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
public class CourseTeacherController implements CourseTeacherApi {

    @Autowired
    private CourseTeacherService courseTeacherService;


/*    //查询课程教师信息
    @GetMapping("/courseTeacher/list/{courseBaseId}")
    public CourseTeacherDTO queryCourseTeacher(@PathVariable Long courseId) {

        Long companyId = SecurityUtil.getCompanyId();

        CourseTeacherDTO courseTeacherDTO = courseTeacherService.queryCourseTeacher(courseId,companyId);

        return courseTeacherDTO;
    }*/

    @GetMapping("/courseTeacher/list/{courseBaseId}")
    public List<CourseTeacherDTO> queryCourseTeacher(@PathVariable Long courseBaseId) {
        Long companyId = SecurityUtil.getCompanyId();
        List<CourseTeacherDTO> teacherDTOList = courseTeacherService.queryCourseTeacher(courseBaseId, companyId);
        return teacherDTOList;
    }


    //创建或修改课程教师信息
    @PostMapping("/courseTeacher")
    public CourseTeacherDTO createOtModifyCourseTeacher(@RequestBody CourseTeacherVO courseTeacherVO) {

        Long companyId = SecurityUtil.getCompanyId();

        CourseTeacherDTO courseTeacherDTO1 = CourseTeacherConvert.INSTANCE.vo2dto(courseTeacherVO);

        CourseTeacherDTO courseTeacherDTO = courseTeacherService.CreateOrModifyCourseTeacher(courseTeacherDTO1,companyId);

        return courseTeacherDTO;

    }

    @DeleteMapping("/courseTeacher/course/{courseBaseId}/{courseTeacherId}")
    public void deleteCourseTeacher(@PathVariable("courseBaseId") Long courseBaseId, @PathVariable("courseTeacherId") Long courseTeacherId) {

        courseTeacherService.deleteCourseTeacher(courseBaseId,courseTeacherId);

    }
}
